package com.zjmzxfzhl.modules.app.entity;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.zjmzxfzhl.common.core.base.BaseEntity;
import com.zjmzxfzhl.common.core.validator.constraints.LengthForUtf8;
import javax.validation.constraints.NotNull;

import com.zjmzxfzhl.modules.app.form.AlarmSetVo;
import com.zjmzxfzhl.modules.sys.entity.SysUser;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * 【】实体类
 * 
 * @author 张森荣
 */
@Data
@TableName("T_APP_ALARM_SET")
public class AppAlarmSet extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * ID
     */
    @TableId
//    @NotNull
    @LengthForUtf8(max = 32)
    private String setId;

    /**
     * 提醒设置{type:类型(00.每周,01.每月,02.一次),weekDay:每周几,monthDay:每月几号,setTime:提醒时间}
     */
//    @NotNull
    @LengthForUtf8(max = 255)
    @JsonIgnore
    private String alarmSet;

    /**
     * 提醒说明
     */
//    @NotNull
    private String content;

    /**
     * 设置类型
     */
    @NotNull
    @LengthForUtf8(max = 2)
    private String setType;

    /**
     * 设置类型ID
     */
    @NotNull
    @LengthForUtf8(max = 32)
    private String setTypeId;

    /**
     * 事务名称
     */
    @NotNull
    @LengthForUtf8(max = 100)
    private String name;

    /**
     * 设置状态
     */
//    @NotNull
    @LengthForUtf8(max = 2)
    private String status;

    @TableField(exist = false)
    private List<SysUser> userList =new ArrayList<>();

    public AlarmSetVo getAlarmSetVo() {
        if (getAlarmSet()!=null) {
            return JSON.parseObject(getAlarmSet(),AlarmSetVo.class);
        } else {
            return null;
        }
    }

    public void setAlarmSetVo(AlarmSetVo alarmSetVo) {
        if (alarmSetVo!=null) {
            setAlarmSet(JSON.toJSONString(alarmSetVo));
        } else {
            setAlarmSet(null);
        }
    }
}